#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

int n, m;
int a[N][N];
int b[N][N];
int ans1, ans2, ans3;
string s1, s2, s3;
int dp[N][N];
char act[N][N];
void solve(int v, int& ans, string& s) {
  rep(i, 1, n) rep(j, 1, n) {
    int k = 0, x = a[i][j];
    if (x == 0)
      k = 1;
    else {
      while (x % v == 0) x /= v, k++;
    }
    b[i][j] = k;
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[1][1] = b[1][1];
  rep(i, 1, n) {
    rep(j, 1, n) {
      if (i != 1 && dp[i][j] > dp[i - 1][j] + b[i][j]) {
        act[i][j] = 'D';
        dp[i][j] = dp[i - 1][j] + b[i][j];
      }
      if (j != 1 && dp[i][j] > dp[i][j - 1] + b[i][j]) {
        act[i][j] = 'R';
        dp[i][j] = dp[i][j - 1] + b[i][j];
      }
    }
  }
  ans = dp[n][n];
  int x = n, y = n;
  while (x != 1 || y != 1) {
    s.push_back(act[x][y]);
    if (act[x][y] == 'D')
      x--;
    else
      y--;
  }
  reverse(s.begin(), s.end());
}
bool find_zero(int& x, int& y) {
  rep(i, 1, n) rep(j, 1, n) {
    if (!a[i][j]) {
      x = i, y = j;
      return true;
    }
  }
  return false;
}
bool solve_zero(int& ans, string& s) {
  int x = -1, y = -1;
  if (find_zero(x, y)) {
    ans = 1;
    rep(i, 1, x - 1) s.push_back('D');
    rep(j, 1, y - 1) s.push_back('R');
    rep(i, x, n - 1) s.push_back('D');
    rep(j, y, n - 1) s.push_back('R');
    return true;
  } else {
    ans = 1e8;
    return false;
  }
}
void solve() {
  cin >> n;
  rep(i, 1, n) rep(j, 1, n) cin >> a[i][j];
  solve(2, ans1, s1);
  solve(5, ans2, s2);
  solve_zero(ans3, s3);
  int mn = min({ans1, ans2, ans3});
  if (ans1 == mn)
    cout << ans1 << endl << s1 << endl;
  else if (ans2 == mn)
    cout << ans2 << endl << s2 << endl;
  else
    cout << ans3 << endl << s3 << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}